package com.adjy.pathbuilders.commons;

/**
 * This class provides methods for checking methods arguments.
 */
public class Preconditions {
	/**
	 * Check if the given reference is not equal to null.
	 * @param object The reference.
	 * @param message An error message used in the case of object is null.
	 * @throws IllegalArgumentException if object is equal to null.
	 */
	public static void checkNotNull(Object object, String message) {
		if (object == null) {
			throw new IllegalArgumentException(message);
		}
	}
	
	/**
	 * Check if the given boolean expression is true.
	 * @param value the boolean expression.
	 * @param message An error message used in the case of value is false.
	 * @throws IllegalArgumentException if value is false.
	 */
	public static void check(boolean value, String message) {
		if (!value) {
			throw new IllegalArgumentException(message);
		}
	}
}
